/*
 ============================================================================
 Name        : Enums_Tads.h
 Author      : SOogle
 Version     : 1.0
 Copyright   : All rights reserved
 Description : FUSELAGE - FUSE FAT32 FILE SYSTEM
 ============================================================================
 */

#ifndef ENUMS_TADS_H_
#define ENUMS_TADS_H_

/*
 ============================================================================
 ENUMERADORES
 ============================================================================
 */

enum NIPC_TYPE {HANDSHAKE=0,
	LECTURA=1,
	LECTURA_OK = 11,
	ESCRITURA=2,
	ESCRITURA_OK=21,
	LECTURA_ERROR=10,
	ESCRITURA_ERROR=20,
	INFOCONSOLA=3,
	CLEAN=4,
	TRACE1=51,
	TRACE2=52,
	TRACE3=53,
	TRACE4=54,
	TRACE5=55,
	SIZEPEDIDOS=56,
	TEMPO=57
};

enum MODO_INICIO_TYPE
{
	CONNECT = 100,
	LISTEN = 200
};

enum PEDIDO_TYPE
{
	PEDIDO_CONSOLA = -2
};

enum ALGORITMO_TYPE{
	CON_INANICION = 300,
	SIN_INANICION = 400
};

/*
 ============================================================================
 TIPO DE DATO - ARCHIVO DE CONFIGURACION
 ============================================================================
 */

typedef struct config{
	char ModoInicio[50];
	char AlgoritmoPlanificacion[50];
	char PathArchivo[150];
	char PathLog[150];
	int32_t PuertoEscuchaPpd;
	char IPRaid[16];
	int32_t PuertoRaid;
	int32_t LogActivado;
	char DiscoID[100];
	int32_t Cylinders;
	int32_t Heads;
	int32_t Sectors;
	int32_t tamanioListaScan;
	int32_t RPM;
	int32_t TiempoLectura;
	int32_t TiempoEscritura;
	int32_t TiempoEntrePistas;
	int32_t tiempoRetardoEscritura;
	int32_t cantClientesMaxPFS;
	char PathConsola[150];
	char SocketUNIX[20];
}__attribute__ ((__packed__)) struct_config;

/*
 ============================================================================
 TIPO DE DATO - PROTOCOLO NIPC
 ============================================================================
 */

typedef struct protocoloNIPC{
	int32_t type;
	int32_t payloadlength;
	t_pedido payload;
}__attribute__ ((__packed__)) nipc;

/*
 ============================================================================
 TIPO DE DATO - PROTOCOLOS DEFINIDOS PARA LA COMUNICACION CON LA CONSOLA
 ============================================================================
 */

//ESTRUCTURA DE LOS PEDIDOS QUE PUEDEN VENIR DE LA CONSOLA

typedef struct info{
	char *respuesta;
}__attribute__ ((__packed__))pedido_info;

typedef struct clean{
	int32_t sectorInicial;
	int32_t sectorFinal;
}__attribute__ ((__packed__))pedido_clean;

typedef struct trace1{
	int32_t s1;
}__attribute__ ((__packed__))pedido_t1;

typedef struct trace2{
	int32_t s1;
	int32_t s2;
}__attribute__ ((__packed__))pedido_t2;

typedef struct trace3{
	int32_t s1;
	int32_t s2;
	int32_t s3;
}__attribute__ ((__packed__))pedido_t3;

typedef struct trace4{
	int32_t s1;
	int32_t s2;
	int32_t s3;
	int32_t s4;
}__attribute__ ((__packed__))pedido_t4;

typedef struct trace5{
	int32_t s1;
	int32_t s2;
	int32_t s3;
	int32_t s4;
	int32_t s5;
}__attribute__ ((__packed__))pedido_t5;

//CABECERA DEL PAQUETE DEL PROTOCOLO NIPC

typedef struct cabeceraPaquete{
	int32_t type;
	int32_t payloadlength;
}__attribute__ ((__packed__)) cabecera_paquete;

//ESTRUCTURA DE LAS RESPUESTAS DEL TRACE

typedef struct respuesta_trace
{
	int32_t posicionActual;
	int32_t sectorSolicitado;
	float tiempoConsumido;
	int32_t proximoSector;
}__attribute__ ((__packed__)) respuesta_trace;

typedef struct protocoloINFO_respuesta
{
	cabecera_paquete cabecera;
	int32_t posicionActual;
}__attribute__ ((__packed__))protocoloINFO_respuesta;

typedef struct protocoloCLEAN_respuesta
{
	cabecera_paquete cabecera;
	int32_t respuestaClean;
}__attribute__ ((__packed__))protocoloCLEAN_respuesta;

typedef struct protocoloTRACE_respuesta
{
	cabecera_paquete cabecera;
	respuesta_trace payload;
	int32_t *sectoresRecorridos;
}__attribute__ ((__packed__))protocoloTRACE_respuesta;

#endif /* ENUMS_TADS_H_ */
